<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <h3>添加员工页面</h3>
  <form >
      <input type="text" name="name" placeholder="员工姓名"><br>
      <input type="text" name="job" placeholder="员工岗位"><br>
      <input type="text" name="sal" placeholder="员工工资"><br>
      <input type="button" value="新增" @click="add()"><br>
  </form>
<!--引入axios和vue-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.14/vue.js"></script>
  <script>
      let v = new Vue({
          el:"form",
          data:{},
          methods:{
              add(){
                  let formData = new FormData(document.querySelector("form"));
                  axios.post("/add",formData).then(function (response) {
                      alert("新增成功");
                      //location:浏览器地址对象，location.href指定浏览器跳转的页面,/代表首页index.html
                      location.href="/";//回到首页
                  })
              }
          }
      })
  </script>

</body>
</html>